<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" href="zw.ico">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>testDemo</title>
<script src="../../jquery.min.js" type="text/javascript"></script>
<script src="swfupload.js" type="text/javascript"></script>
<style type="text/css">
html,body{
	width: 1200px;
	margin: 0 auto;
	background-color: #f0f0f0;
	font-size: 12px;
}
body, div, dl, dt, dd, ul, ol, li,
h1, h2, h3, h4, h5, h6, pre, code,
form, fieldset, legend, input, button,
textarea, p, blockquote, th, td {
    margin: 0;
    padding: 0;
}
</style>
</head>
<body>

<div>
	<span id="spanButtonPlaceHolder"></span>
</div>
<div>
	<button id="zw">点击试试</button>
</div>
<div>
	<input type="file" value="" id="zFile" name="zFile" multiple="true" />
</div>
<div>
	<button id="zw2">再点击试试</button>
</div>
<script type="text/javascript">
$(function(){
	$("#zw").click(function(){

	})
	$("#zw2").click(function(){
		$("#zFile").trigger("click");
	})
})


var swfu;
$(function(){
	var settings = {
		flash_url : "swfupload.swf",
		upload_url: "PhotoUploatServlet?action=doPost&upType=6",
		post_params: {"J_ft_brandId":"zw"},
		use_query_string: true,
		file_size_limit : "1 MB",
		file_types : "*.jpg",  //允许所有类型时请使用 *.*
		file_types_description : "All Files",
		file_upload_limit : 0,
		file_queue_limit : 0,
		debug: false,

		// Button settings
		button_image_url: "../vendor/file_img.png",
		button_width: "61",
		button_height: "22",
		button_placeholder_id: "spanButtonPlaceHolder",
		button_text: '',
		button_text_style: ".theFont { font-size: 16; }",
		button_text_left_padding: 12,
		button_text_top_padding: 3,
		
		// The event handler functions are defined in handlers.js
		file_dialog_complete_handler : fileDialogComplete,
		upload_start_handler : uploadStart,
		upload_error_handler : uploadError,
		upload_success_handler : uploadSuccess
	};

	swfu = new SWFUpload(settings);
});

function fileDialogComplete(numFilesSelected, numFilesQueued) {
	try {
		this.startUpload();
	} catch (ex)  {
        this.debug(ex);
	}
}
function uploadStart(file) {
	alert("开始");
	return true;
}
function uploadSuccess(file, serverData) {
	try {
		serverData = JSON.parse(serverData);
    	if (serverData.returnCode=='0') {
    		alert("成功");
    	}else{
    		alert("失败");
    	}
	} catch (ex) {
		this.debug(ex);
	}
}

function uploadError(file, errorCode, message) {
	try {
    	alert("上传失败!");
	} catch (ex) {
        this.debug(ex);
    }
}

</script>
</body>
</html>